home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1K4XP2L (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.8 KB  |  85 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.Rectangle;
  5.  
  6. public class MetalUtils {
  7.    static void drawActiveButtonBorder(Graphics g, int x, int y, int w, int h) {
  8.       drawFlush3DBorder(g, x, y, w, h);
  9.       g.setColor(MetalLookAndFeel.getPrimaryControl());
  10.       g.drawLine(x + 1, y + 1, x + 1, h - 3);
  11.       g.drawLine(x + 1, y + 1, w - 3, x + 1);
  12.       g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  13.       g.drawLine(x + 2, h - 2, w - 2, h - 2);
  14.       g.drawLine(w - 2, y + 2, w - 2, h - 2);
  15.    }
  16.  
  17.    static void drawButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) {
  18.       if (active) {
  19.          drawActiveButtonBorder(g, x, y, w, h);
  20.       } else {
  21.          drawFlush3DBorder(g, x, y, w, h);
  22.       }
  23.  
  24.    }
  25.  
  26.    static void drawDark3DBorder(Graphics g, int x, int y, int w, int h) {
  27.       g.translate(x, y);
  28.       drawFlush3DBorder(g, 0, 0, w, h);
  29.       g.setColor(MetalLookAndFeel.getControl());
  30.       g.drawLine(1, 1, 1, h - 2);
  31.       g.drawLine(1, 1, w - 2, 1);
  32.       g.setColor(MetalLookAndFeel.getControlShadow());
  33.       g.drawLine(1, h - 2, 1, h - 2);
  34.       g.drawLine(w - 2, 1, w - 2, 1);
  35.       g.translate(-x, -y);
  36.    }
  37.  
  38.    static void drawDark3DBorder(Graphics g, Rectangle r) {
  39.       drawDark3DBorder(g, r.x, r.y, r.width, r.height);
  40.    }
  41.  
  42.    static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) {
  43.       drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active);
  44.       g.setColor(MetalLookAndFeel.getControlDarkShadow());
  45.       g.drawRect(x, y, w - 3, h - 3);
  46.       g.drawLine(w - 2, 0, w - 2, 0);
  47.       g.drawLine(0, h - 2, 0, h - 2);
  48.    }
  49.  
  50.    static void drawDisabledBorder(Graphics g, int x, int y, int w, int h) {
  51.       g.translate(x, y);
  52.       g.setColor(MetalLookAndFeel.getControlShadow());
  53.       g.drawRect(0, 0, w - 1, h - 1);
  54.    }
  55.  
  56.    static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) {
  57.       g.translate(x, y);
  58.       g.setColor(MetalLookAndFeel.getControlDarkShadow());
  59.       g.drawRect(0, 0, w - 2, h - 2);
  60.       g.setColor(MetalLookAndFeel.getControlHighlight());
  61.       g.drawRect(1, 1, w - 2, h - 2);
  62.       g.setColor(MetalLookAndFeel.getControl());
  63.       g.drawLine(0, h - 1, 1, h - 2);
  64.       g.drawLine(w - 1, 0, w - 2, 1);
  65.       g.translate(-x, -y);
  66.    }
  67.  
  68.    static void drawFlush3DBorder(Graphics g, Rectangle r) {
  69.       drawFlush3DBorder(g, r.x, r.y, r.width, r.height);
  70.    }
  71.  
  72.    static void drawPressed3DBorder(Graphics g, int x, int y, int w, int h) {
  73.       g.translate(x, y);
  74.       drawFlush3DBorder(g, 0, 0, w, h);
  75.       g.setColor(MetalLookAndFeel.getControlShadow());
  76.       g.drawLine(1, 1, 1, h - 2);
  77.       g.drawLine(1, 1, w - 2, 1);
  78.       g.translate(-x, -y);
  79.    }
  80.  
  81.    static void drawPressed3DBorder(Graphics g, Rectangle r) {
  82.       drawPressed3DBorder(g, r.x, r.y, r.width, r.height);
  83.    }
  84. }
  85.